<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/7/4 0004
 * Time: 下午 4:41
 */
namespace app\index\controller;
use think\Controller;
use app\index\model\Member;
class Login extends Controller{
    public function index(){
        return $this->fetch('user/login');
    }
    public function doLogin(){
        $user=new Member();
        $user->email = input('email');
        $user->password = input('password');

        $result1 = $this->validate($user,'Vlogin');
        if(true!==$result1){
//            $this->error($result1);
            echo $result1;
        }
        else{
            //验证用户名
            $tn=db('member_content')->where('email',input('email'))->find();
            //验证密码
            $tp=db('member')->where('password',md5(input('password')))->find();
            if(empty($tn)||empty($tp)){
                echo '用户名或密码错误';
            }
            else{
            //验证通过
            //cookie,非法登录
            cookie('id',$tp['username'],3600);
            //验证通过，页面跳转
    //        $this->redirect(url('index/index'));
            $arr=0;
            echo $arr;
            }
        }
    }
    public function loginout(){
        cookie('id',null);
        cookie('username',null);
        $this->redirect(url('login/index'));
    }
}